package custom;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.qianfeng.lingshijia.R;

import utils.DownloadUtils;

/**
 * Created by Mr.xingkong on 2016/1/11.
 * 该控件时用于囤货必备和热销单品的共用控件，他们两者只是数据不同，布局完全一样，故实现他们只需要adapter不同
 */
public class Commodity_stockpile extends LinearLayout
{
    private Context context;
    ImageView commodityPicture;
    TextView commodityName,commodityPrice,commodityMessage;
    public ImageView shoppingCart_iv_stock;
    public Commodity_stockpile(Context context)
    {
        super(context);
        this.context = context;
        initView();
    }

    public Commodity_stockpile(Context context, AttributeSet attrs)
    {
        super(context, attrs);
        this.context = context;
        initView();
    }

    private void initView()
    {
        LayoutInflater.from(context).inflate(R.layout.commodity_stockpile_layout,this);
        commodityPicture = (ImageView) findViewById(R.id.commodity_pic);
        commodityName = (TextView) findViewById(R.id.commodity_name);
        commodityPrice = (TextView) findViewById(R.id.commodity_price);
        commodityMessage = (TextView) findViewById(R.id.commodity_message);
         shoppingCart_iv_stock = (ImageView) findViewById(R.id.shoppingCart_iv_stock);
    }

    /**
     * 设置数据
     * @param picUrl
     * @param name
     * @param price
     * @param message
     */
    public void setData(String picUrl,String name ,String price ,String message)
    {
        DownloadUtils.LoadPicture(picUrl, commodityPicture);
        commodityName.setText(name);
        commodityPrice.setText(price);
        commodityMessage.setText(message);
    }
}
